// import Cookies from 'js-cookie';
import { useCookies } from '@vueuse/integrations/useCookies';

const TokenKey = 'ims_tokenId';
const UserInfoKey = 'ims_userInfo';
const Cookies = useCookies();

/* 获取tokenId */
export function getToken(): string {
	return Cookies.get(TokenKey) as string;
}

/* 设置tokenId */
export function setToken(token: string) {
	return Cookies.set(TokenKey, token);
}

/* 移除tokenId */
export function removeToken() {
	return Cookies.remove(TokenKey);
}

interface UserInfo {
	id: number;
	loginName: string;
	userName: string;
}
/* 获取userInfo*/
export function getUserInfo(): UserInfo | null {
	if (Cookies.get(UserInfoKey)) {
		return Cookies.get(UserInfoKey);
	}
	return null;
}

/* 设置userInfo */
export function setUserInfo(token: string) {
	return Cookies.set(UserInfoKey, token);
}

/* 移除userInfo */
export function removeUserInfo() {
	return Cookies.remove(UserInfoKey);
}
